import Vue from 'vue'

const state = {
  nameList: [],
}

const mutations = {
  SET_ROUTER_NAME_LIST: (state, routerItem) => {
    let currentNameItem = state.nameList.find(item => item.path == routerItem.path);
    if (currentNameItem) {
      let index = _.findIndex(state.nameList, item => item.path == routerItem.path);
      currentNameItem = _.cloneDeep(routerItem)
      Vue.set(state.nameList, index, currentNameItem)
    } else {
      state.nameList.push(routerItem)
    }
  },
  REMOVE_ALL_NAME_CONFIG: (state) => {
    state.nameList = []
  }
}
export default {
  namespaced: true, state, mutations
}
